//
// Created by 86156 on 25-7-5.
//

#ifndef MOTOR_DRIVER_H
#define MOTOR_DRIVER_H
#include "tim.h"
#include <stdint.h>

#include "pid_driver.h"

#define Motor1_PWM_HTIMx &htim1
#define Motor2_PWM_HTIMx &htim1
#define Motor3_PWM_HTIMx &htim1
#define Motor4_PWM_HTIMx &htim1
#define Motor5_PWM_HTIMx &htim3
#define Motor6_PWM_HTIMx &htim3
#define Motor7_PWM_HTIMx &htim3
#define Motor8_PWM_HTIMx &htim3

#define Motor1_PWM_CHANNELx TIM_CHANNEL_1
#define Motor2_PWM_CHANNELx TIM_CHANNEL_2
#define Motor3_PWM_CHANNELx TIM_CHANNEL_3
#define Motor4_PWM_CHANNELx TIM_CHANNEL_4
#define Motor5_PWM_CHANNELx TIM_CHANNEL_1
#define Motor6_PWM_CHANNELx TIM_CHANNEL_2
#define Motor7_PWM_CHANNELx TIM_CHANNEL_3
#define Motor8_PWM_CHANNELx TIM_CHANNEL_4


#define MINTHROTTLE						1500 //
#define MAXTHROTTLE_LIMIT				1500+500*0.7 //
#define MAXTHROTTLE_LIMIT_INV 			1500-500*0.7 //
#define COMMANDER_MINCHECK 				1550 //
#define COMMANDER_MINCHECK_INV 			1450 //
#define COMMANDER_MINCHECK_RELATIVE 	25   //
#define COMMANDER_MINCHECK_RELATIVE_INV -25  //

typedef struct
{
    struct
    {
        TIM_HandleTypeDef *PWM_htim;
        uint32_t PWM_Channel;
        float PWM;
    }PIN;

}Motor_t;

extern Motor_t Motor1,Motor2,Motor3,Motor4,Motor5,Motor6,Motor7,Motor8;
void Motor_Init();

#endif //MOTOR_DRIVER_H
